﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;

using Newtonsoft.Json;

namespace AjaxControlFramework
{
	public class JsonDotNetCallbackSerializer : CallbackSerializer
	{
        //------// Properties \\--------------------------------------------\\
        
        //------\\ Properties //--------------------------------------------//



        //------// Constructors \\------------------------------------------\\
        public JsonDotNetCallbackSerializer()
        { }
        //------\\ Constructors //------------------------------------------//



		//------// Methods \\-----------------------------------------------\\
		public override string SerializeCallbackResult(Dictionary<string, object> callbackResult)
		{
            return JsonConvert.SerializeObject(callbackResult, Formatting.None);
		}


        public override string SerializeException(Exception exception)
        {
            return JsonConvert.SerializeObject(exception, Formatting.None);
        }


        public override string SerializeObject(object obj)
        {
            return JsonConvert.SerializeObject(obj, Formatting.None);
        }


        public override object DeserializeObject(string jsonString)
        {
            return JsonConvert.DeserializeObject(jsonString);
        }


		public override T DeserializeObject<T>(string strObj)
		{
            return JsonConvert.DeserializeObject<T>(strObj);
		}
		//------\\ Methods //-----------------------------------------------//
	}
}
